using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Terra.Core.Common.ApiResponse;
using Terra.Core.Common.Models.Pagination;
using Terra.Data.Entities.Identity;
using Terra.Data.Models.Identity;

namespace Terra.Service.Identity.Interfaces;

/// <summary>
/// 角色服务接口
/// </summary>
public interface IRoleService
{
    /// <summary>
    /// 获取角色
    /// </summary>
    /// <param name="id">角色ID</param>
    /// <returns>角色实体</returns>
    Task<ApiResponse<Role>> GetRoleAsync(Guid id);

    /// <summary>
    /// 分页查询角色
    /// </summary>
    /// <param name="query">查询条件</param>
    /// <returns>分页结果</returns>
    Task<ApiResponse<PagedList<RoleItemDto>>> GetPagedRolesAsync(RoleQueryDto query);

    /// <summary>
    /// 获取角色详情
    /// </summary>
    /// <param name="id">角色ID</param>
    /// <returns>角色详情</returns>
    Task<ApiResponse<RoleDetailDto>> GetRoleDetailAsync(Guid id);

    /// <summary>
    /// 创建角色
    /// </summary>
    /// <param name="dto">创建参数</param>
    /// <returns>创建的角色ID</returns>
    Task<ApiResponse<Guid>> CreateRoleAsync(RoleCreateDto dto);

    /// <summary>
    /// 更新角色
    /// </summary>
    /// <param name="dto">更新参数</param>
    /// <returns>更新结果</returns>
    Task<ApiResponse> UpdateRoleAsync(RoleUpdateDto dto);

    /// <summary>
    /// 删除角色
    /// </summary>
    /// <param name="id">角色ID</param>
    /// <returns>删除结果</returns>
    Task<ApiResponse> DeleteRoleAsync(Guid id);

    /// <summary>
    /// 批量删除角色
    /// </summary>
    /// <param name="dto">批量删除参数</param>
    /// <returns>删除结果</returns>
    Task<ApiResponse<List<Guid>>> BatchDeleteRolesAsync(RoleBatchDeleteDto dto);

    /// <summary>
    /// 为角色分配用户
    /// </summary>
    /// <param name="dto">分配参数</param>
    /// <returns>分配结果</returns>
    Task<ApiResponse> AssignUsersToRoleAsync(RoleAssignUsersDto dto);

    /// <summary>
    /// 从角色中移除用户
    /// </summary>
    /// <param name="dto">移除参数</param>
    /// <returns>移除结果</returns>
    Task<ApiResponse> RemoveUsersFromRoleAsync(RoleAssignUsersDto dto);

    /// <summary>
    /// 获取角色用户列表
    /// </summary>
    /// <param name="roleId">角色ID</param>
    /// <returns>用户列表</returns>
    Task<ApiResponse<IList<User>>> GetUsersInRoleAsync(Guid roleId);

    /// <summary>
    /// 获取角色选择列表
    /// </summary>
    /// <returns>角色选择列表</returns>
    Task<ApiResponse<List<RoleSelectDto>>> GetRoleSelectListAsync();

    /// <summary>
    /// 检查角色名是否存在
    /// </summary>
    /// <param name="roleName">角色名称</param>
    /// <param name="excludeRoleId">排除的角色ID</param>
    /// <returns>是否存在</returns>
    Task<ApiResponse<bool>> IsRoleNameExistsAsync(string roleName, Guid? excludeRoleId = null);
}